//
//  WelcomeViewController.m
//  艾听歌
//
//  Created by dllo on 16/6/7.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "WelcomeViewController.h"

@interface WelcomeViewController ()<UIScrollViewDelegate>
@property(nonatomic, strong) UIPageControl *pageC; /**< 小圆点 */
@property(nonatomic, strong) UIScrollView *welSV; /**< 背景scrollView */

@end

@implementation WelcomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self createScrollView];
    [self createpage];
}
// 创建 scrollView
- (void)createScrollView {
    self.welSV = [[UIScrollView alloc] initWithFrame:self.view.frame];
    self.welSV.contentSize = CGSizeMake(WIDTH * 3, HEIGHT);
    //    welSV.backgroundColor = [UIColor redColor];
    self.welSV.delegate = self;
    self.welSV.pagingEnabled = YES;
    [self.view addSubview:self.welSV];
    
    UIImageView *imgView1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    imgView1.image = [UIImage imageNamed:@"引导页首页"];
    [self.welSV addSubview:imgView1];
   
    
    UIImageView *imgView2 = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH, 0, WIDTH, HEIGHT)];
    imgView2.image = [UIImage imageNamed:@"引导页第二页"];
    [self.welSV addSubview:imgView2];
    
    
    UIImageView *imgView3 = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH * 2, 0, WIDTH, HEIGHT)];
    imgView3.image = [UIImage imageNamed:@"34658PICTah_1024"];
    // 开启图片用户交互
    imgView3.userInteractionEnabled = YES;
    [self.welSV addSubview:imgView3];
    
    
    // 进入首页按钮
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
    btn.frame = CGRectMake(self.view.center.x - 40, HEIGHT - 100, 80, 30);
    [btn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    btn.layer.borderWidth = 1;
    btn.layer.borderColor = [[UIColor whiteColor] CGColor];
    [btn setTitle:@" 进入首页 " forState:(UIControlStateNormal)];
    [btn addTarget:self action:@selector(push) forControlEvents:(UIControlEventTouchUpInside)];
    [imgView3 addSubview:btn];
    
}
// 创建小圆点
- (void)createpage {
    self.pageC = [[UIPageControl alloc] initWithFrame:CGRectMake(self.view.center.x - 40, HEIGHT - 75, 80, 30)];
    //    self.pageC.backgroundColor = [UIColor redColor];
    self.pageC.numberOfPages = 3;
    // 当前页
    self.pageC.currentPage = 0;
    [self.view addSubview:self.pageC];
    
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    // 根据scrollView的偏移量 修改小圆点
    self.pageC.currentPage = self.welSV.contentOffset.x / WIDTH;
}
// 按钮点击方法 跳页面
- (void)push {
    [self presentViewController:self.tabBar animated:YES completion:^{
        
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
